<template>
	<view class="box">
		<u-tabs
		class="tabs"
		:list="list1" 
		@click="click"
		:activeStyle="{
			color: '#444',
			transform: 'scale(1.05)',
			'font-size':'28rpx'
		}"
		lineWidth="0"
		:itemStyle="{
			'width':'144rpx',
			'height':'56rpx',
			'background':'#F7F8FA',
			'color':'#888',
			'font-size':'28rpx',
			'border-radius':'28rpx',
			'margin':'0 8rpx'
		}"
		:inactiveStyle="{
			color: '#888888',
			transform: 'scale(1)',
			'font-size':'28rpx'
		}"></u-tabs>
		
		<!-- <u-loading-page :loading="loading"></u-loading-page> -->
		<u-loading-icon :show="loading"></u-loading-icon>
		<u-empty
		style="margin-top:320rpx ;"
				v-if="!list.length && !loading"
		        mode="search"
		>
		</u-empty>
		<template v-if="list.length && !loading">
			<Fly v-if="currentIndex == 0" :isComment="false" :list="list" :type="'coCreate'"></Fly>
			<inspirationTower v-if="currentIndex == 1" :list="list"></inspirationTower>
			<poem v-if="currentIndex == 2" :list="list"></poem>
			<text-island v-if="currentIndex == 3" :list="list"></text-island>
			<star v-if="currentIndex == 4" :list="list"></star>
			<log-list v-if="currentIndex == 5" :isInput="true" :list="list" source="gong" color1="rgb(68, 68, 68)"></log-list>
		</template>
	</view>
</template>

<script>
	import Fly from '@/components/search/Fly.vue'//飞离洞
	import inspirationTower from '@/components/search/InspirationTower.vue'//灵感塔
	import poem from "@/components/search/poem.vue"; //诗心园
	import textIsland from '@/components/search_co/text_island.vue';//文心岛
	import star from '@/components/search_co/star.vue'//星河
	import logList from '@/components/logList.vue' //游记
	import { Search } from '@/common/api/search.js'
	export default {
		props:{
			search:{
				type:String,
				default:''
			}
		},
		components:{
			textIsland,
			star,
			logList,
			Fly,
			inspirationTower,
			poem
		},
		data() {
			return {
				list1: [{
					name: '飞离洞',
				}, {
					name: '灵感塔',
				}, {
					name: '诗心园'
				}, {
					name: '文心岛'
				}, {
					name: '星河'
				},{
					name: '游记'
				}],
				currentIndex:0,
				loading:false,
				list:[]
			}
		},
		mounted() {
			this.getList();
		},
		methods:{
			async getList() {
				this.loading = true;
				try {
					const res = await Search({
						type:7,
						content:this.search,
						type2:this.currentIndex+1
					});
					this.list = res.data.list.data;
					this.loading = false;
					console.log('resssss111s',res);
				} catch {
					this.loading = false;
				}
			},
			click(e) {
				console.log('eee',e);
				this.currentIndex = e.index;
				this.getList();
			}
		}
	}
</script>

<style scoped lang="scss">
	.box { 
		width: 100%;
		height: 100%;
		padding: 0 0 0;
		box-sizing: border-box;
	}
</style>